package handler

import (
	"github.com/gin-gonic/gin"
	"micros/api/params"
	"micros/golbal"
	"micros/model"
	"net/http"
)

func Like(c *gin.Context) {

	like := params.Like{}

	if err := c.ShouldBind(&like); err != nil {
		c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
		return
	}

	m := model.Like{

		UserId:    like.UserId,
		MomentsId: like.MomentId,
	}
	golbal.DB.Debug().Create(&m)

	c.JSON(http.StatusOK, gin.H{
		"code": 200,
		"msg":  "点赞成功",
	})
}
